<!--
 * @Author: Rachel 943701297@qq.com
 * @Date: 2022-08-01 10:08:49
 * @LastEditors: Rachel 943701297@qq.com
 * @LastEditTime: 2022-08-09 16:46:55
 * @FilePath: \代码c:\Users\94370\Desktop\面向工作学习\笔记\learning-notes\Vue_Code\JS_pro.html
 * @Description: JS 高级语法学习笔记
 * 
 * Copyright (c) 2022 by Rachel 943701297@qq.com, All Rights Reserved. 
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>test</title>
    <style></style>
  </head>
  <body>
    <script>
      var adder = {
        base: 1,

        add: function (a) {
          var f = (v) => v + this.base;
          return f(a);
        },

        addThruCall: function (a) {
          var f = (v) => v + this.base;
          var b = {
            base: 2,
          };

          return f.call(b, a);
        },
      };
      console.log(adder.add(1)); // 输出 2
      console.log(adder.addThruCall(1)); // 仍然输出 2
    </script>
  </body>
</html>
